package com.museum.data;

import java.util.HashMap;
import java.util.Map;

import android.util.Log;

import com.museum.model.Mp_User_Profile;

public class Mp_User_Profile_Handler {
	Mp_User_Profile mpuserprofile;
	XmlRpc xmlrpc;
	private String _username;
	private String _password;
	public Mp_User_Profile_Handler(String username, String password){
		_username = username;
		_password = password;
		xmlrpc = new XmlRpc();
		mpuserprofile = new Mp_User_Profile();
		this.Parse();
	}
	public Mp_User_Profile getMp_User_Profile(){
		return mpuserprofile;
	}
	private void Parse(){
		HashMap<String, String> params = new HashMap<String, String>();
		params.put("username", _username);
      	params.put("password", _password); 
      	
      	Map<String, Object> response = xmlrpc.call("mp.user.profile", params);
      	for (Map.Entry<String, Object> entry : response.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();	            
          
            if(key.equals("user_id")){
            	mpuserprofile.setUser_Id(value.toString());
            }else if(key.equals("user_name")){
            	mpuserprofile.setUser_Name(value.toString());
            }
			else if(key.equals("display_name")){
				mpuserprofile.setDisplay_Name(value.toString());   	
			}
			else if(key.equals("email")){
				mpuserprofile.setEmail(value.toString());
			}
			else if(key.equals("register_date")){
				mpuserprofile.setRegister_Date(value.toString());
			}

      	}
	}
}
